package acwing.算法进阶打卡;/**
 * @author： li
 * @date： 2022-03-15 21:23
 * @version 1.0
 */
import java.util.*;
import java.io.*;
public class 递归实现组合型枚举Ⅱ {
    static int n;
    static int m;
    static char[] ans;
    static char[] yuan;
    static boolean[] flag = new boolean[10];
    static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out));
    static void dfs(int sum,int index) throws IOException {
        if(sum==m){
            for(int i=0;i<n;i++) {
                if (flag[i])
                    out.write(yuan[i] + " ");
            }
            out.write("\n");
            return;
        }
        for(int i=index;i<n;i++)
            {
                if(i != 0 &&!flag[i-1]&& yuan[i-1] == yuan[i]) continue;
                flag[i]=true;
                dfs(sum+1,i+1);
                flag[i]=false;

            }

    }
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        yuan= new char[n];
        ans = new char[10];
        yuan=sc.next().toCharArray();
//        System.out.println(yuan);
        Arrays.fill(flag,false);
        dfs(0,0);
        sc.close();
        out.flush();
    }
}